<template>
  <div class="setting-container">
    <div class="setting-content">
      <div class="setting-content-header">
        <el-button
          type="primary"
          :icon="ArrowLeftBold"
          @click="backHome()"
          size="large"
          text
        >
          返回首页
        </el-button>
      </div>
      <el-container style="margin-top: 32px">
        <el-aside class="setting-aside">
          <el-menu :default-active="active" router>
            <el-menu-item index="profile" class="setting-menu-item">
              <el-icon>
                <List />
              </el-icon>
              <span>个人资料</span>
            </el-menu-item>
            <el-menu-item index="account" class="setting-menu-item">
              <el-icon>
                <user />
              </el-icon>
              <span>账号设置</span>
            </el-menu-item>
            <el-menu-item index="common" class="setting-menu-item">
              <el-icon>
                <setting />
              </el-icon>
              <span>通用设置</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main class="setting-main">
          <el-scrollbar>
            <!-- 路由组件出口的位置 -->
            <router-view v-slot="{ Component }">
              <transition mode="out-in" name="el-fade-in-linear">
                <!-- 渲染layout一级路由组件的子路由 -->
                <component :is="Component" />
              </transition>
            </router-view>
          </el-scrollbar>
        </el-main>
      </el-container>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRoute, useRouter } from 'vue-router'
import { ArrowLeftBold } from '@element-plus/icons-vue'
import { ref } from 'vue'

const router = useRouter()
const route = useRoute()
const active = ref(route.name as string)

const backHome = () => {
  router.push('/home')
}
</script>

<style scoped lang="scss">
.setting-container {
  height: 100vh;
  background-color: #f2f3f5;

  .setting-content {
    padding: 6vh 12vw 0;

    .setting-content-header {
      padding: 8px 12px;
      background-color: var(--el-menu-bg-color);
      border-radius: 8px;
    }

    .setting-aside {
      height: 560px;
      background-color: var(--el-menu-bg-color);
      width: 220px;
      padding: 10px;
      border-radius: 8px;
    }

    .setting-main {
      width: calc(100vw - 280px);
      min-height: 580px;
      background-color: var(--el-menu-bg-color);
      margin-left: 22px;
      border-radius: 8px;
      padding: 0px;
    }

    .setting-menu-item {
      font-size: 17px;
      font-weight: 500;
    }
  }
}

.el-menu {
  border-right: none;
}
</style>
